home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-02
/
pas_all.zip
/
TI446.ASC
< prev
next >
Wrap
Text File
|
1992-08-12
|
4KB
|
199 lines
PRODUCT : Turbo Pascal NUMBER : 446
VERSION : 1.0
OS : WIN
DATE : August 12, 1992 PAGE : 1/3
TITLE : Changing Color of Buttons with Bitmaps
{$R bnn}
{ The above resource assumes that you have a dialog name
'dialog_1' that contains three buttons of id 101, 102, 103.
There should also be six bitmaps in the resource of value 1101,
3101, 5101 which hold the bitmaps for the red button and 1102,
3102, 5102 which hold the bitmaps for the blue button. Clicking
the blue button should change the third button blue and clicking
the red button should change it red.
}
uses WinTypes, WinProcs, WObjects, bwcc;
const
id_Red = 101;
id_Blue = 102;
id_Change = 103;
IsRed: Boolean = False;
IsBlue: Boolean = False;
type
TApp = object(TApplication)
procedure InitMainWindow; virtual;
end;
PMyDialog = ^TMyDialog;
TMyDialog = object(TDialog)
Red, Blue: array[0..2] of hBitMap;
constructor Init(AParent :PWindowsObject; AName: PChar);
destructor Done; virtual;
procedure ChangeToRed(var Message: TMessage);
virtual id_First + id_Red;
procedure ChangeToBlue(var Message: TMessage);
virtual id_First + id_Blue;
end;
{ TApp }
procedure TApp.InitMainWindow;
begin
MainWindow := New(PMyDialog, Init(Nil, 'dialog_1'));
end;
{ TMyDialog }
PRODUCT : Turbo Pascal NUMBER : 446
VERSION : 1.0
OS : WIN
DATE : August 12, 1992 PAGE : 2/3
TITLE : Changing Color of Buttons with Bitmaps
constructor TMyDialog.Init(AParent :PWindowsObject; AName:
PChar);
begin
TDialog.Init(AParent, AName);
Red[0] := LoadBitMap(hInstance, PChar(1101));
Red[1] := LoadBitMap(hInstance, PChar(3101));
Red[2] := LoadBitMap(hInstance, PChar(5101));
Blue[0] := LoadBitMap(hInstance, PChar(1102));
Blue[1] := LoadBitMap(hInstance, PChar(3102));
Blue[2] := LoadBitMap(hInstance, PChar(5102));
end;
destructor TMyDialog.Done;
var
I: Integer;
begin
TDialog.Done;
if Not IsRed then
for I := 0 to 2 do
DeleteObject(Red[I]);
if Not IsBlue then
for I := 0 to 2 do
DeleteObject(Blue[I]);
end;
procedure TMyDialog.ChangeToRed(var Message: TMessage);
begin
SendDlgItemMessage(HWindow, id_Change, bbm_SetBits, 0,
LongInt(@ Red));
InvalidateRect(GetDlgItem(HWindow, id_Change), Nil, True);
IsRed := True;
IsBlue := False;
end;
procedure TMyDialog.ChangeToBlue(var Message: TMessage);
begin
SendDlgItemMessage(HWindow, id_Change, bbm_SetBits, 0,
LongInt(@ Blue));
InvalidateRect(GetDlgItem(HWindow, id_Change), Nil, True);
IsRed := False;
IsBlue := True;
end;
PRODUCT : Turbo Pascal NUMBER : 446
VERSION : 1.0
OS : WIN
DATE : August 12, 1992 PAGE : 3/3
TITLE : Changing Color of Buttons with Bitmaps
var
App: TApp;
begin
App.Init('Test');
App.Run;
App.Done;
end.
DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.